package com.bwie.controller;

import com.bwie.pojo.User;
import com.bwie.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    //登录
    @RequestMapping("/login")
    @ResponseBody
    public int login(User user){
        return userService.login(user);
    }

    //跳转至登录页面
    @RequestMapping("/goLogin")
    public String goLogin(){
        return "login";
    }

    //跳转至登录信息过期页面
    @RequestMapping("/goError")
    public String goError(){
        return "errorLogin";
    }

    //回显用户名
    @RequestMapping("/echo")
    @ResponseBody
    public User echo(Integer userId){
        return userService.echo(userId);
    }
}
